package com.yaozheng.vocationaltraining.dialog.time;

import android.content.Context;
import android.view.Gravity;

import com.yaozheng.vocationaltraining.R;
import com.yaozheng.vocationaltraining.dialog.BaseDialog;
import com.yaozheng.vocationaltraining.fragment.BaseFragment;
import com.yaozheng.vocationaltraining.view.time.SelectTimeDatePickerDialogView;
import com.yaozheng.vocationaltraining.view.time.SelectTimeDatePickerDialogView_;

/**
 * 选择时间对话框
 */
public class SelectTimeDateDialog extends BaseDialog {
    SelectTimeDatePickerDialogView selectTimeDatePickerDialogView;

    private String determineRunMethod;

    private BaseFragment baseFragment;

    public SelectTimeDateDialog(BaseFragment baseFragment) {
        this(baseFragment.getBaseActivity());
        this.baseFragment = baseFragment;
    }

    public SelectTimeDateDialog(Context context) {
        this(context, R.style.baseDialogStyleTheme, true, Gravity.CENTER);
    }

    public SelectTimeDateDialog(Context context, int theme, boolean isCover, int gravity) {
        super(context, theme, isCover, gravity);
    }


    public SelectTimeDatePickerDialogView getSelectTimeDatePickerDialogView() {
        return selectTimeDatePickerDialogView;
    }


    public String getDetermineRunMethod() {
        return determineRunMethod;
    }

    public void setDetermineRunMethod(String determineRunMethod) {
        this.determineRunMethod = determineRunMethod;
    }

    @Override
    public void setContentView() {
        selectTimeDatePickerDialogView = SelectTimeDatePickerDialogView_.build(getContext());
        selectTimeDatePickerDialogView.setBaseDialogEventProcess(this);
        setContentView(selectTimeDatePickerDialogView);
    }

    /**
     * 确定
     */
    public void determine() {
        if (determineRunMethod == null) {
            determineRunMethod = "selectTimeDateDialogDetermine";
        }
        if (baseFragment != null) {
            baseFragment.runMethod(determineRunMethod);
        } else {
            baseActivity.runMethod(determineRunMethod);
        }
    }
}
